<template>
  <div>
    <TopNav title="朱朱的跟帖哟" />
    <!-- 每一个评论列表 -->
    <div class="list">
      <div class="item" v-for="mycomment in mycommentsList" :key="mycomment.id">
        <div class="date">2020-10-10 &nbsp;&nbsp;&nbsp;&nbsp;10:25</div>
        <div class="parent" v-if="mycomment.parent">
          <!-- <div class="nickname">回复</div> -->
          <div class="nickname">
            回复
            {{
              mycomment.parent.user.nickname || mycomment.parent.user.username
            }}
          </div>
          <!-- <div class="content">阿信是张信哲么？</div> -->
          <div class="content">{{ mycomment.parent.content }}</div>
        </div>
        <!-- <div class="mainContent">不是</div> -->
        <div class="mainContent">{{ mycomment.content }}</div>
        <!-- <div class="article">原文：xxxx</div> -->
        <div class="article" v-if="mycomment.post">
          原文： {{ mycomment.post.title }}
        </div>
        <div v-else class="article">原文： 该贴已被删除</div>
      </div>
    </div>
  </div>
</template>

<script>
import TopNav from "../../components/TopNav";
export default {
  components: {
    TopNav,
  },
  data() {
    return {
      mycommentsList: [],
    };
  },
  created() {
    this.$axios({
      headers: {
        Authorization: localStorage.getItem("token"),
      },
      url: "/user_comments/",
    }).then((res) => {
      console.log(res.data);
      const { data } = res.data;
      this.mycommentsList = data;
      //   console.log(this.mycommentsList);
    });
  },
};
</script>

<style lang="less" scoped>
.list {
  .item {
    padding: 14 / 360 * 100vw;
    border-bottom: 1px solid #888;
    .date {
      font-size: 14 / 360 * 100vw;
      color: #888;
    }
    .parent {
      background-color: #e4e4e4;
      margin: 10 / 360 * 100vw 0;
      padding: 10 / 360 * 100vw;
      .nickname {
        font-size: 14 / 360 * 100vw;
      }
      .content {
        font-size: 16 / 360 * 100vw;
        margin-top: 10 / 360 * 100vw;
      }
    }
    .mainContent {
      font-size: 16 / 360 * 100vw;
      color: #333;
    }
    .article {
      font-size: 14 / 360 * 100vw;
      color: #888;
      margin-top: 10 / 360 * 100vw;
      //   如果超出一行未省略号该设置：
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
  }
}
</style>